from flask import render_template
from blueprints import like_blueprint
from models import QueryMultipleInstances, Like, QueryOneInstance, Blog, PackInstance
from tools.decorate import pack_session


@like_blueprint.route('/my/page/like', methods=['GET'])
@pack_session
def get_my_page_of_like(data):
    likes = QueryMultipleInstances(Like,{'uid':data['session']['uid']})

    dic=[]
    for i in likes:
       blog = QueryOneInstance(Blog,{'id':i.pid})
       if blog is not None:
           dic.append(blog)

    if dic is not []:
        data.update(PackInstance(dic))
    return render_template('pages/like/blog.html',data=data)